<?php
/**
 * $Id: hooks.php 710 2014-11-13 07:59:10Z hitesh $
 * 
 * This file can not be redistributed to anyone without the permission of Giga Promoters
 * Copyright 2005 - 2008, Giga Promoters
 * 						  608 Aggarwal Cyber Plaza
 *						  Netaji Subhash Place, Delhi - 110034
 *						  www.gigapromoters.com
 * 
 *
 * This is parent of parent class of a controller and should not be edited ever without permission.
 * @version 			$Rev: 710 $
 * @lastModifiedBy		$LastChangedBy: hitesh $
 * @lastChanged			$Date: 2014-11-13 13:29:10 +0530 (Thu, 13 Nov 2014) $
 * @copyright 			Giga Promoters (www.gigapromoters.com)
 * 
 */

/**
 * Might be useful for user cookie handling
 *
 * @param unknown_type $controller
 */
function UsersbeforeFilterhook(&$controller)
{
	/*// check if cookie exists
	App::import('Component', 'Cookie');
	$cookieObj = new CookieComponent();
	$cookieObj->initialize($controller,array());
	$cookie = $cookieObj->read('userInfo');
	if($cookie)
		$this->Auth->login($cookie);*/
	
	//$controller->set('blocks', array('sidebar'=>'from hook'));
	//$loginForm = $controller
	//$controller->setBlockContent('sidebar', 0, 'loginBox', false);

}

function UsersdashboardHook($controller)
{
	$controller->dashboard[] = array('id'=>'users_dashboard', 'title'=>'Users', 'url'=>'/admin/users/stats');
}

function UsersafterLoginHook($controller)
{
	/*
	$userCredit  = $controller->User->UserCredit->field('credits',array('user_id ='.$controller->Session->read('Auth.User.id')));
	if($userCredit <1)
	{
		$controller->redirect('/pages/unpaid');
	}
	*/
}

function UsersbeforeRegisterHook($controller)
{
}

/**
 * This method will set all uncrawlable links in robots.txt through SEO plugin
 * @param $controller - SEO controller
 * @return unknown_type

function UsersSetDisallowedUrlsHook($controller)
{
	$conditions = array('User.profile_hidden'=>1);
	$hiddenUsers = ClassRegistry::init('Users.User')->find('all', compact('conditions'));
	foreach($hiddenUsers as $user)
	{
		$controller->_addDisallowedUrl($user['User']['profile_url']);
	}
}
 */

function UsersBeforeAssetSaveHook($ctrl)
{
	if($ctrl->uploaderModel == 'User')
	{
		$ctrl->itemId = $ctrl->Session->read('Auth.User.id');
	}
}

function UsersBuildAdminMenuHook($backend)
{
	$backend->addMenuItem(ADMIN_USERS, __("Users"), "/users/users/index");
}

function UsersAfterComponentInitHook($ctrl)
{
	if(cr('cmsInstalled') && @strpos($_SERVER['REQUEST_URI'],'/cms/startTestSession') === false)
	{
		Configure::registerConfigModelLoder("UserContentConfig",'Users.UserContentConfig');
	}
}
?>